import request from '@/utils/request'

// 添加收藏
export function addFavorite(userId, questionId) {
  return request({
    url: '/userFavorite/addFavorite',
    method: 'post',
    params: {
      userId,
      questionId
    }
  })
}

// 取消收藏
export function removeFavorite(userId, questionId) {
  return request({
    url: '/userFavorite/removeFavorite',
    method: 'delete',
    params: {
      userId,
      questionId
    }
  })
}

// 获取用户收藏列表
export function getUserFavorites(userId) {
  return request({
    url: `/userFavorite/getUserFavorites/${userId}`,
    method: 'get'
  })
}

// 检查是否已收藏
export function checkFavorite(userId, questionId) {
  return request({
    url: '/userFavorite/checkFavorite',
    method: 'get',
    params: {
      userId,
      questionId
    }
  })
}

// 分页获取用户收藏列表
export function getUserFavoritesPage(params) {
  return request({
    url: '/userFavorite/getUserFavoritesPage',
    method: 'post',
    data: params
  })
}

export default {
  addFavorite,
  removeFavorite,
  getUserFavorites,
  checkFavorite,
  getUserFavoritesPage
}
